const config =                  require('./webpack.config');
const HtmlWebpackPlugin =       require('html-webpack-plugin');
const MiniCssExtractPlugin =    require("mini-css-extract-plugin");

module.exports = {
    mode: 'production',
    entry:{
        main: config.entry,
        moral: './style/themes/moral.scss',
        cotton: './style/themes/cotton.scss',
        flower: './style/themes/flower.scss',
    },
    stats: config.devServer.stats,
    // output: Object.assign({}, config.output, {publicPath: '/Pages/mianmian/vip'}),
    output: Object.assign({}, config.output, {publicPath: '/Pages/huibaitang/vip'}),
    context: config.context,
    resolve: config.resolve,
    performance: {hints: false},
    optimization: config.optimization,
    module: {
        rules: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                use: [
                    'babel-loader'
                ],
            },
            {
                test: /\.css$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    // 'style-loader',
                    {loader: "css-loader", options: {minimize: true || {/* CSSNano Options */}}},
                ]
            },
            {
                test: /\.scss$/,
                exclude: /node_modules/,
                use: [
                    MiniCssExtractPlugin.loader,
                    // 'style-loader',
                    {loader: "css-loader", options: {minimize: true || {/* CSSNano Options */}}},
                    'sass-loader',
                ],
            },
            {
                test: /\.(eot?.+|svg?.+|gif?.+|ttf?.+|otf?.+|woff?.+|woff2?.+)$/,
                use: 'file-loader?name=assets/[name].[hash:8].[ext]'
            },
            {
                test: /\.(jpg|jpeg|png|gif|ico|svg)$/,
                use: [
                    // if less than 10Kb, bundle the asset inline, if greater, copy it to the dist/assets
                    // folder using file-loader
                    'url-loader?limit=10240&name=assets/[name].[hash:8].[ext]'
                ],
            }

        ],
    },
    plugins: [
        new HtmlWebpackPlugin({
            path: config.output.path,
            filename: 'index.html',
            template: './public/index.prod.html',
            chunks: ['vendor', 'main'],
        }),
        new MiniCssExtractPlugin({filename: "[name]-[hash].css"}),
    ],
};
